/************************************************************************
* Controller class, handle user interaction, update model
* Author : Shaolan
* Version : 1.0
* Website : http://shaolan.net
*/
#ifndef MODEL_HEADER
        #include "model.hpp"
        #define MODEL_HEADER 1
#endif

#ifndef LIBGE_HEADER
        #include <libge/libge.h>
        #define LIBGE_HEADER 1
#endif

#define N_KEYS 8
#define MOVE_DELAY 10
#define SWAP_DELAY 40
#define DOWN_DELAY 5	


class Controller {
        protected:
                Model * model;
                ge_Keys * input;
                ge_Keys * repeatListener;
				ge_Timer* timeline;
				int move;
				int down;
				int swap;
				bool started;
                // Callback method
                Signal crossCallback();
                Signal circleCallback();
                Signal squareCallback();
                Signal triangleCallback();
                Signal upCallback();
                Signal downCallback();
                Signal leftCallback();
                Signal rightCallback(); 
                Signal rCallback(); 
                Signal lCallback(); 
        public:
                typedef Signal (Controller::*Callback)();
                static int Keys[];
                static Callback action[];
                Controller();
                Controller(Model *);
                ~Controller();
				void init();
                Model * getModel() const;
                void setModel(Model *);
                bool update();  
};
